function Obj(value) {
    this.value = value
    this.next = null
}

Obj.prototype[Symbol.iterator] = function () {
    return {
        next: function () {
            if (this.next === null) {
                return {
                    done: true,
                    value: undefined,
                }
            } else {
                let res = {
                    done: false,
                    value: this.value,
                }
                return res
            }
        }
    }
}

let one = new Obj(1);
let two = new Obj(2);
let three = new Obj(3);

one.next = two;
two.next = three;

for (let i of one) {
    console.log(i); // 1, 2, 3
}
